home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Utilities / Apple File Exchange / AppleFile Exchange Translator / ExampleTrans / AFETrans.p next >
Text File  |  1989-04-13  |  7KB  |  253 lines

  1. Unit AFETrans;
  2.  
  3.                                 INTERFACE
  4.  
  5. Uses                            
  6. {$LOAD MacLoad.L}    MemTypes,QuickDraw,osIntf,toolIntf,packIntf,macPrint,script;
  7.  
  8. CONST
  9.   {* translator routine commands *}
  10.     trn_Init      = 0;    { do any translator routine initialization }
  11.     trn_Finis     = 1;    { do any clean up and disposal }
  12.     trn_Get       = 2;    { Return current status }
  13.     trn_Set          = 3;    { Set current status }
  14.     trn_Active    = 4;    { User has requested item be checked in menu }
  15.     trn_Inactive  = 5;    { User has requested item be unchecked in menu }
  16.     trn_NewName      = 6;    { If recognized, return new name for selected file }
  17.     trn_File      = 7;    { If recognized, convert the selected file }
  18.     trn_Recognize = 8;    { Return NoErr if selected file is recognized }
  19.     trn_Appear      = 9;    { This routine is now listed in a menu }
  20.     trn_Disappear = 10;    { This routine is no longer listed in a menu }
  21.     trn_Load      = 11; { Pre-load any resources you might need }
  22.     trn_About      = 12; { Provide "About this translator" information }
  23.     trn_GetSettings=13;    { Get default information about the translator }
  24.     trn_SetSettings=14; { Set default information about the translator }
  25.     
  26.   {* translator status bits *}
  27.     trnActive    = $0001;    { item is checked }
  28.     trnGray        = $0002;    { item is grayed-out }
  29.     trnBold        = $0010;    { item is bold }
  30.     trnItalic    = $0020;    { item is italicized }
  31.     trnUnderline= $0040;    { item is underlined }
  32.     trnOutline    = $0080;    { item is outlined }
  33.     trnShadow    = $0100;    { item is shadowed }
  34.     trnAbout    = $0200;    { About information is available for the item}
  35.     trnUser1    = $1000;    { user bit 1 }
  36.     trnUser2    = $2000;    { user bit 2 }
  37.     trnUser3    = $4000;    { user bit 3 }
  38.     
  39.   {* miscellaneous constants *}
  40.  
  41.     maxdestnames = 15;
  42.     
  43.     accept         = noerr;
  44.     unAccept    = 1;
  45.     trnCancel    = 2;
  46.  
  47.   {* File system op codes *}
  48.     FFGetVInfo        = 1;    FFSetVInfo        = 2;    FFFlushVol        = 5;
  49.     FFOpen            = 9;    FFOpenRF        = 10;    FFLockRange        = 11;
  50.     FFUnLockRange    = 12;    FFRead            = 13;    FFWrite            = 14;
  51.     FFGetFPos        = 15;    FFSetFPos        = 16;    FFGetEOF        = 17;
  52.     FFSetEOF        = 18;    FFAllocate        = 19;    FFAllocContig    = 20;
  53.     FFFlushFile        = 21;    FFClose            = 22;    FFCreate        = 23;
  54.     FFDirCreate        = 24;    FFDelete        = 25;    FFGetFInfo        = 26;
  55.     FFSetFInfo        = 27;    FFSetFLock        = 28;    FFRstFLock        = 29;
  56.     FFSetFVers        = 30;    FFRename        = 31;    FFGetCatInfo    = 32;
  57.     FFSetCatInfo    = 33;    FFOpenWD        = 35;    FFCloseWD        = 36;
  58.     FFGetWDInfo        = 37;    FFOKFName        = 41;    FFMakeFName        = 47;
  59.     FFXGetCatInfo    = 50;    FFXSetCatInfo    = 51;
  60.         
  61.     foreignFS         = '4NFS';
  62.  
  63.   {* Extended CatInfo constants *}
  64.  
  65.      mdos        = 'mdos';
  66.     pdos        = 'pdos';
  67.     
  68.     {ProDOS access bits}
  69.     pdReadable    = $01;                { File may be read }
  70.     pdWritable    = $02;                { File may be written to }
  71.     pdChanged    = $20;                { File has changed since last backup }
  72.     pdRename    = $40;                { File may be renamed }
  73.     pdDestroy    = $80;                { File may be destroyed }
  74.     
  75.     pdNormal    = $C3;                { A normal ProDOS file }
  76.     pdLocked    = $01;                { A locked ProDOS file }
  77.     
  78.     {ProDOS storage types}
  79.     pdSeedling    = $01;                { File is a seedling, only one data block }
  80.     pdSapling    = $02;                { File is a sapling, 2 to 256 data blocks }
  81.     pdTree        = $03;                { File is a tree, 257 to 32768 data blocks }
  82.     pdSubDir    = $0D;                { File is a subdirectory }
  83.  
  84.     {ProDOS version numbers}
  85.     ProDos1_0    = 0;                { ProDOS 1.0 }
  86.     
  87.     {MSDOS Attribute bits}
  88.     msReadOnly    = $01;                { File is read-only }
  89.     msHidden    = $02;                { File is hidden }
  90.     msSystem    = $04;                { File is a system file }
  91.     msVolume    = $08;                { Directory is the root }
  92.     msSubDir    = $10;                { File is a subdirectory }
  93.     msArchive    = $20;                { File has been written to and closed }
  94.  
  95.     {****************************************************
  96.      *
  97.      * constants for tprocs
  98.      *
  99.      ***************************************************}
  100.     
  101.     tDstTooShort = -501;
  102.     
  103.     cfMacintosh    =    0;
  104.     cfASCIi        =    1;
  105.     cfIBMPC        =    2;
  106.     
  107.     transInit    =    0;
  108.     transDone    =    1;
  109.     translotohi    =    2;
  110.     transhitolo    =    3;
  111.     
  112.     trMultiDestFont     =    1;
  113.     trMultiDestCountry    =    2;
  114.     trNonOnetoOne        =    4;
  115.     trOverStrike        =    8;
  116.  
  117. TYPE
  118.     nameREC = RECORD
  119.         namecnt : integer;
  120.         names   : array[0..maxdestnames] of str255;
  121.         end;
  122.     nameptr = ^nameRec;
  123.     namehdl = ^nameptr;
  124.  
  125.     translateRec = RECORD
  126.         trnLogproc    :    procptr;    { pointer to error log procedure }
  127.         trnstatproc    :    procptr;    { pointer to status procedure }
  128.         trnfrID        :    integer;    { resource ID of source FS }
  129.         trntoID        :    integer;    { resource ID of dest FS }
  130.         trnfrData    :    ptr;        { pointer to source FS global data }
  131.         trntoData    :    ptr;        { pointer to dest FS global data }
  132.         trnResrv    :     integer;    { used by InterFile }
  133.         trnfrVRef    :    integer;    { volume ref of source }
  134.         trntoVRef    :    integer;    { volume ref of dest }
  135.         trnfrPar    :    longint;    { parent ID of source }
  136.         trntoPar    :    longint;    { parent ID of dest }
  137.         trnnames    :    namehdl;    { handle to names of source/dest files}
  138.         trnTested    :    boolean;    { TRUE if you've already looked at this
  139.                                         file for recognition }
  140.         trnAccepted    :    boolean;    {if TRNTESTED is true, this flag shows
  141.                                         whether you recognized the file }
  142.         trnCountry    :    integer;    { country ID }
  143.         END;
  144.     trnPtr = ^translateRec;
  145.  
  146.   {* parameter blocks for extended CatInfo calls *}
  147.  
  148.     XFSType     = (Mac,ProDOS,MSDOS);
  149.     XCInfoPtr     = ^XCInfoPBRec;
  150.     XCInfoPBRec = RECORD
  151.     { In the memo this was descrived as a pointer not a record }
  152.         CInfo: CInfoPBRec;
  153.         CASE xfs : XFSType OF
  154.             Mac : 
  155.                 (filler3    : longint);
  156.             ProDOS :
  157.                 (auxtype    : integer; { ProDOS auxilary file type }
  158.                 access        : signedbyte;{ read,write perm etc. }
  159.                 storagetype    : signedbyte;{ seedling,sapling, etc }
  160.                 version        : signedbyte;{ version ProDOS used }
  161.                 minvers        : signedbyte);{ earliest ProDOS version useable }
  162.             MSDOS :
  163.                 (attrib        : signedbyte; { read,write, hidden, etc }
  164.                 filler4        : signedbyte);
  165.         END;
  166.     
  167.     pdosHndl    = ^pdosPtr;
  168.     pdosPtr        = ^pdosRec;
  169.     pdosRec        = RECORD
  170.         auxtype        : integer;
  171.         access        : signedbyte;
  172.         storagetype    : signedbyte;
  173.         version        : signedbyte;
  174.         minvers        : signedbyte;
  175.         END;
  176.         
  177.     
  178.     mdosHndl    = ^mdosPtr;
  179.     mdosPtr        = ^mdosRec;
  180.     mdosRec        = RECORD
  181.         attrib        : signedbyte;
  182.         filler3        : signedbyte;
  183.         END;
  184.  
  185.     TPRCEntry = RECORD
  186.         tprcID         : integer;
  187.         curCharFam    : integer;
  188.         altCountry    : integer;
  189.         altCharFam    : integer;
  190.         end;
  191.         
  192.     tprf = RECORD
  193.         lastEntry    : integer;
  194.         reserved    : array[1..31] of integer;
  195.         tprocs        : array[1..1000] of TPRCEntry;
  196.         end;
  197.     tprfPtr = ^tprf;
  198.     tprfHndl = ^tprfPtr;
  199.  
  200.     header = RECORD
  201.         branch    : longint;
  202.         sig        : resType;
  203.         resnum    : integer;
  204.         versnum    : integer;
  205.         vers    : string[15];
  206.         flags    : integer;
  207.         loCntry    : integer;
  208.         loCFam    : integer;
  209.         hiCntry    : integer;
  210.         hiCFam    : integer;
  211.         hdrrsrv    : array[0..3] of longint;
  212.         end;
  213.     hdrPtr = ^header;
  214.     hdrHndl = ^hdrPtr;
  215.  
  216.     TransText = RECORD
  217.         trPtr    : Ptr;
  218.         trLen    : Longint;
  219.         trFont    : integer;
  220.         end;
  221.     
  222.     TransPB = RECORD
  223.         verb        : integer;
  224.         featureflags: integer;
  225.         result        : OSErr;
  226.         newCntry    : integer;
  227.         srcText        : TransText;
  228.         dstText        : TransText;
  229.         tpRsrv        : array[0..3] of longint;
  230.         end;
  231.  
  232.  
  233. function CallFS(msg : integer; fsdata : ptr; pb :ptr; 
  234.                 async : boolean; fsroutine : handle) : OSErr;
  235.     INLINE $2057,$2050,$4E90;
  236.  
  237. procedure CallLog(str : str255; cr : boolean; Indent : boolean; Logproc : procptr);
  238.     INLINE $205F, $1F5F, $0001, $4E90;
  239.  
  240. procedure CallErrLog(str : str255; cr : boolean; Indent : boolean; Logproc : procptr);
  241.     INLINE $205F, $1F5F, $0001, $002F, $0080, $0001, $4E90;
  242.  
  243. function CallStat(statmsg : str255; statpct : integer; destfnum : integer;
  244.                 statproc : procptr) : boolean;
  245.     INLINE $205F, $4E90;
  246.  
  247. function CallTProc(VAR params : TransPB; self : hdrHndl) : OSErr;
  248.     INLINE $2057,$2050,$4E90;
  249.  
  250.  
  251.                                 IMPLEMENTATION
  252.  
  253. end.